﻿@using MvcAgenda.Resources;
@model MvcAgenda.Domain.Entities.aevent
@{
    ViewBag.Title = Events.DetailsTitle;
    UrlHelper url = new UrlHelper(HttpContext.Current.Request.RequestContext);
    String listUrl = url.RouteUrl(new { Controller = "Events", Action = "Index" });
}
<h2>@Events.DetailsTitle</h2>

<script>
    function gettoken() {
        var tokenTag = '@Html.AntiForgeryToken()'
        var token = $(tokenTag).val()
        return token
    }
    function errorHappens() {
        $('.bottom-right').notify({ message: { text: "@Events.eventDeleteErrorMsg"} }).show();
    }
    function goToList() {
        location.href = '@listUrl';
    }
    $(document).on("click", ".deleteLink", function (e) {
        var link = $(this).attr("href"); // "get" the intended link in a var
        var description = $(".display-field:first").text() + " - " + $(".display-field:eq(1)").text();
        e.preventDefault();
        bootbox.confirm("@Events.eventDeleteConfirmMsg<br/>" + description, function (result) {
            if (result) {
                var formData = { __RequestVerificationToken: gettoken() };
                $.ajax({
                    url: link,
                    type: "POST",
                    data: formData,
                    success: function (data) {
                        if (data) {
                            $('.bottom-right').notify({ message: { text: description + "@Events.eventDeleteSucessMsg"} }).show();
                            window.setTimeout(goToList, 1000);                            
                        }
                        else {
                            errorHappens();
                        }
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        errorHappens();
                    }
                });
            }
        });
    });
</script>

<fieldset>
    <legend></legend>
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.title)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.title)
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.description)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.description)
            </div>
        </div>
    </div>
    @*<div class="row">
    <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12"><div class="display-label">
         @Html.DisplayNameFor(model => model.user_id)
    </div>    </div>
    <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
    <div class="display-field">
        @Html.DisplayFor(model => model.user_id)
    </div>    </div>
</div>*@
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.location_id)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.location.label)
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.startTime)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.startTime)
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.endTime)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.endTime)
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
            <div class="display-label">
                @Html.DisplayNameFor(model => model.url)
            </div>
        </div>
        <div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
            <div class="display-field">
                @Html.DisplayFor(model => model.url)
            </div>
        </div>
    </div>
</fieldset>
<p>
    @Html.FontAwesomeActionLink(Events.backToListLink, "Index", null, "fa fa-hand-o-left")
    |
    @Html.FontAwesomeActionLink(Events.editLink, "Edit", new { id = Model.id }, "fa fa-pencil")
    |
    @Html.FontAwesomeActionLink(Events.deleteLink, "Delete", new { id = Model.id }, "fa fa-trash-o", new { @class = "deleteLink" })
</p>
